package com.py.framework.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.py.framework.core.rest.support.RestServiceResult;
import com.py.framework.service.TotalService;

/**
 * 考勤统计
 * @author 11793
 *
 */
@RequestMapping("/total")
@RestController
public class TotalController {
	
	@Autowired
	private TotalService totalService;
	
	@RequestMapping(value = "/getInfo", method = RequestMethod.POST)
	public @ResponseBody RestServiceResult<List<Object>> getInfo(String year,String month) {
		RestServiceResult<List<Object>> result = new RestServiceResult<>();
		//获取当前月的休息天数
		String days = totalService.getdays(year,month);
		List<String> dayList = java.util.Arrays.asList(days.split(","));
		List<String> dayLists = new ArrayList<>();
		for(String day :dayList) {
			if(day.length()<=1) {
				day = "0"+day;
				dayLists.add(day);
			}
		}
		
		result.setData(totalService.getInfo(year,month,dayLists));
		return result;
	}
}
